﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Library;

namespace Sport_Shop
{
    public partial class Adsearch : System.Web.UI.Page
    {
     
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //    load_dulieu_combobox();
            
            
        }

        protected void Tim_Click(object sender, EventArgs e)
        {
            
            if (tbTenSP.Text != null && tbGiaTu.Text == null && tbGiaDen.Text == null)
            {
                Response.Redirect("~/KQTim.aspx?TenSP=" + tbTenSP.Text.ToString());
            }

            if (tbTenSP.Text == null && tbGiaTu.Text != null && tbGiaDen.Text != null)
            {
                Response.Redirect("~/KQTim.aspx?GiaTu=" + tbGiaTu.Text.ToString() + "&GiaDen=" + tbGiaDen.Text.ToString());
            }

            if (tbTenSP.Text != null && tbGiaTu.Text != null && tbGiaDen.Text != null)
            {
                Response.Redirect("~/KQTim.aspx?TenSP=" + tbTenSP.Text.ToString() + "&GiaTu=" + tbGiaTu.Text.ToString() + "&GiaDen=" + tbGiaDen.Text.ToString());
            }

            //else
            //{
            //    Response.Redirect("~/KQTim.aspx?TenLoai=" + cbLoaiSP.SelectedItem.Text.ToString());
            //}



            //if (cbLoaiSP.SelectedItem.Value != null)
            //{
            //    Response.Redirect("~/KQTim.aspx?&LoaiSP=" + cbLoaiSP.SelectedItem.Value.ToString());
            //}


            //if (cbLoaiSP.SelectedItem.Value != null && cbHangSX.SelectedItem.Value == null)
            //{
            //    string loai = cbLoaiSP.SelectedItem.Value.ToString();
            //    Response.Redirect("~/KQTim.aspx?LoaiSP=" + loai);

            //}
            //else if (cbLoaiSP.SelectedItem.Value == null && cbHangSX.SelectedItem.Value != null)
            //{
            //    string hsx = cbHangSX.SelectedItem.Value.ToString();
            //    Response.Redirect("~/KQTim.aspx?HSX=" + hsx);
            //}
        }

        //private void load_dulieu_combobox()
        //{
        //    DataAccess da = new DataAccess();
        //    string sql = "SELECT * FROM LoaiSanPham";
        //    cbLoaiSP.DataSource = da.GetDataTable(sql);
        //    cbLoaiSP.DataTextField = "TenLoai";
        //    cbLoaiSP.DataValueField = "MaLoai";
        //    cbLoaiSP.DataBind();




        //    //string sql3 = "SELECT * FROM HangSanXuat";
        //    //cbHangSX.DataSource = da.GetDataTable(sql3);
        //    //cbHangSX.DataTextField = "TenHSX";
        //    //cbHangSX.DataValueField = "MaHSX";
        //    //cbHangSX.DataBind();
            
            
        //}
     }
 }
